package com.otaku.admin.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.otaku.admin.dao.entity.Role;
import com.otaku.admin.dao.entity.UserRole;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserRoleMapper extends BaseMapper<UserRole> {
    @Select("select * from sys_user_role " +
            "where user_id = #{userRole.userId} and role_id = #{userRole.role_id}")
    List<UserRole> findByUserAndRole(@Param("userRole") UserRole userRole);

    @Delete("delete from sys_user_role " +
            "where user_id = #{userRole.userId} and role_id = #{userRole.roleId}")
    void deleteByUserAndRole(@Param("userRole") UserRole userRole);
}
